package com.suray.attendance.common.utils;

public enum ModuleType {
    DEFAULT("基础模块"),
    RUN_INFO("运行信息"),
    TASK("任务"),
    ;

    String des;
    ModuleType(String des) {
        this.des = des;
    }

    public String getDes() {
        return des;
    }

    public int getValue() {
        int value = 1;
        for (ModuleType module : ModuleType.values()) {
            if (this.equals(module)) {
                return value;
            }
            value++;
        }

        throw new RuntimeException("错误的ModuleType：" + this);
    }

    public static ModuleType parseModuleType(int value) {
        int v = 1;
        for (ModuleType module : ModuleType.values()) {
            if (v == value) {
                return module;
            }
            v++;
        }

        return null;
    }

    @Override
    public String toString() {
        return des;
    }
}
